<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>用户信息表--${site.name}</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <meta name="description" content="${site.description}"/>
    <meta name="keywords" content="${site.keywords}"/>
    <meta name="author" content="${site.author}"/>
    <link rel="icon" href="${site.logo}">
    <link rel="stylesheet" href="${base}/static/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="//at.alicdn.com/t/font_tnyc012u2rlwstt9.css" media="all" />
    <link rel="stylesheet" href="${base}/static/css/user.css" media="all" />
    <style>
        #ref-msg{
            width: 300px;
            height: 150px;
        }
        .layui-table-cell {
            height: auto;
            line-height: 28px;
        }
    </style>
</head>
<body class="childrenBody">
<fieldset class="layui-elem-field">
  <legend>用户信息表检索</legend>
  <div class="layui-field-box">
    <form class="layui-form" id="searchForm">
        <div class="layui-inline" style="margin-left: 15px">
            <label>用户id:</label>
            <div class="layui-input-inline">
                <input type="text" value="" name="s_userId" placeholder="请输入用户id" class="layui-input search_input">
            </div>
        </div>
    <div class="layui-inline" style="margin-left: 15px">
            <label>昵称:</label>
                <div class="layui-input-inline">
                <input type="text" value="" name="s_userName" placeholder="请输入昵称" class="layui-input search_input">
                </div>
    </div>
    <div class="layui-inline" style="margin-left: 15px">
            <label>手机号:</label>
                <div class="layui-input-inline">
                <input type="text" value="" name="s_phone" placeholder="请输入手机号" class="layui-input search_input">
                </div>
    </div>
        <div class="layui-inline" style="margin-left: 15px">
            <label>市场成员类型:</label>
                <div class="layui-input-inline">
                    <select name="s_memberType">
                        <option value="" selected="">请选择市场成员类型</option>
                        <option value="0" >发电企业</option>
                        <option value="1" >售电企业</option>
                        <option value="2" >电力用户</option>
                    </select>
                </div>
    </div>
        <div class="layui-inline" style="margin-left: 15px">
            <label>是否拉黑:</label>
            <div class="layui-input-inline">
                <select name="s_isDelete">
                    <option value="" selected="">请选择是否拉黑</option>
                    <option value="1" >正常</option>
                    <option value="0" >已拉黑</option>
                    <option value="3" >取消拉黑</option>
                    <option value="2" >已到期</option>
                </select>
            </div>
        </div>
        <div class="layui-inline" style="margin-left: 15px">
            <label>审核状态:</label>
            <div class="layui-input-inline">
                <select name="s_isCheck">
                    <option value="" selected="">请选择审核是否通过</option>
                    <option value="0" >审核中</option>
                    <option value="1" >审核通过</option>
                    <option value="2" >审核拒绝</option>
                </select>
            </div>
        </div>
        <div class="layui-inline" style="margin-left: 15px">
            <label>注册时间：</label>
            <div class="layui-input-inline">
                <input id="startTime" name="s_startTime"  placeholder="注册时间"   autocomplete="off" class="layui-input">
            </div>
            <span>-</span>
            <div class="layui-input-inline">
                <input id="endTime" name="s_endTime" placeholder="注册时间"   autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-inline">
            <a class="layui-btn" lay-submit="" lay-filter="searchForm">查询</a>
        </div>
        <div class="layui-inline" >
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
       <#-- <div class="layui-inline">
            <a class="layui-btn layui-btn-normal" data-type="addElectricityUser">添加用户</a>
        </div>-->
    </form>
  </div>
</fieldset>
<div class="layui-form users_list">
    <table class="layui-table" id="test" lay-filter="demo"></table>
    <script type="text/html" id="userStatus">
        <!-- 这里的 checked 的状态只是演示 -->
        {{#  if(d.delFlag == false){ }}
        <span class="layui-badge layui-bg-green">正常</span>
        {{#  } else { }}
        <span class="layui-badge layui-bg-gray">停用</span>
        {{#  } }}
    </script>
    <script type="text/html" id="barDemo">
        {{#  if(d.isDelete == 1&&d.isCheck==0){ }}
        <a class="layui-btn layui-btn-xs" lay-event="view">查看</a>
        <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="pullBlack">拉黑</a>
        <a class="layui-btn  layui-btn-xs" lay-event="check">审核通过</a>
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="refuse">审核拒绝</a>
        {{# }else if(d.isDelete ==1&&d.isCheck==1){ }}
        <a class="layui-btn layui-btn-xs" lay-event="view">查看</a>
        <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="pullBlack">拉黑</a>
        {{# }else if(d.isDelete ==1&&d.isCheck==2){ }}
        <a class="layui-btn layui-btn-xs" lay-event="view">查看</a>
        <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="pullBlack">拉黑</a>
        {{# }else if(d.isDelete ==0&&d.isCheck==0){ }}
        <a class="layui-btn layui-btn-xs" lay-event="view">查看</a>
        <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
        <a class="layui-btn  layui-btn-xs" lay-event="calPullBlack">取消拉黑</a>
        <a class="layui-btn  layui-btn-xs" lay-event="check">审核通过</a>
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="refuse">审核拒绝</a>
        {{# }else if(d.isDelete ==0){ }}
        <a class="layui-btn layui-btn-xs" lay-event="view">查看</a>
        <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
        <a class="layui-btn  layui-btn-xs" lay-event="calPullBlack">取消拉黑</a>
        {{# }else if(d.isDelete ==2 || d.isDelete ==3 || d.isPerfectInfo ==1){ }}
        <a class="layui-btn layui-btn-xs" lay-event="view">查看</a>
        <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
        {{#  } else { }}
        <a class="layui-btn layui-btn-xs" lay-event="view">查看</a>
        <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
        {{#  } }}
        <a class="layui-btn layui-btn-xs" lay-event="refusePwd">重置密码</a>
    </script>
    <script type="text/html" id="imgTpl">
        {{#  if(d.businessLicense != null){ }}
        <img src="{{ d.businessLicense }}">
        {{#  } }}
      </script>
</div>
<div id="page"></div>
<script type="text/javascript" src="${base}/static/layui/layui.js"></script>
<script type="text/javascript" src="${base}/static/js/tools.js"></script>
<script type="text/javascript" src="${base}/static/layui/lay/modules/laydate.js"></script>
<script>
    layui.use(['layer','form','table','laydate'], function() {
        var layer = layui.layer,
                $ = layui.jquery,
                form = layui.form,
                laydate = layui.laydate,
                table = layui.table;

        laydate.render({
            elem: '#startTime', //指定元素
            type: "datetime",
            done: function (value, date, endDate) {

            }
        });
        laydate.render({
            elem: '#endTime', //指定元素
            type: "datetime"
        });


        //监听工具条
        table.on('tool(demo)', function(obj){
            var data = obj.data;
            if(obj.event === 'view'){
                var editIndex = layer.open({
                    title : "查看",
                    type : 2,
                    content : "${base}/admin/electricityUser/view?id="+data.userId,
                    success : function(layero, index){
                        setTimeout(function(){
                            layer.tips('点击此处返回用户列表', '.layui-layer-setwin .layui-layer-close', {
                                tips: 3
                            });
                        },500);
                    }
                });
                //改变窗口大小时，重置弹窗的高度，防止超出可视区域（如F12调出debug的操作）
                $(window).resize(function(){
                    layer.full(editIndex);
                });
                layer.full(editIndex);
            }
            if(obj.event === 'edit'){
                var editIndex = layer.open({
                    title : "编辑用户",
                    type : 2,
                    content : "${base}/admin/electricityUser/edit?id="+data.userId,
                    success : function(layero, index){
                        setTimeout(function(){
                            layer.tips('点击此处返回用户列表', '.layui-layer-setwin .layui-layer-close', {
                                tips: 3
                            });
                        },500);
                    }
                });
                //改变窗口大小时，重置弹窗的高度，防止超出可视区域（如F12调出debug的操作）
                $(window).resize(function(){
                    layer.full(editIndex);
                });
                layer.full(editIndex);
            }
            if(obj.event === "del"){
                layer.confirm("你确定要删除该用户么？",{btn:['是的,我确定','我再想想']},
                        function(){
                            $.post("${base}/admin/electricityUser/delete",{"id":data.userId},function (res){
                                if(res.success){
                                    layer.msg("删除成功",{time: 1000},function(){
                                        location.reload();
                                    });
                                }else{
                                    layer.msg(res.message);
                                }

                            });
                        }
                )
            }

        if(obj.event === "pullBlack") {
            layer.confirm("你确定要拉黑该用户么？", {btn: ['是的,我确定', '我再想想']},
                function () {
                    $.post("${base}/admin/electricityUser/pullBlack", {"id": data.userId,"type":"0"}, function (res) {
                        if (res.success) {
                            layer.msg("拉黑成功", {time: 1000}, function () {
                                location.reload();
                            });
                        } else {
                            layer.msg(res.message);
                        }

                    });
                }
            )
        }
            if(obj.event === "calPullBlack") {
                layer.confirm("你确定取消拉黑该用户么？", {btn: ['是的,我确定', '我再想想']},
                    function () {
                        $.post("${base}/admin/electricityUser/calPullBlack", {"id": data.userId}, function (res) {
                            if (res.success) {
                                layer.msg("取消成功", {time: 1000}, function () {
                                    location.reload();
                                });
                            } else {
                                layer.msg(res.message);
                            }

                        });
                    }
                )
            }

            if(obj.event === "check") {
                layer.confirm("是否确定审核通过？", {btn: ['是的,我确定', '我再想想']},
                    function () {
                        $.post("${base}/admin/electricityUser/checkPass", {"id": data.userId}, function (res) {
                            if (res.success) {
                                layer.msg("审核成功", {time: 1000}, function () {
                                    location.reload();
                                });
                            } else {
                                layer.msg(res.message);
                            }

                        });
                    }
                )
            }
            if(obj.event === "refuse") {
                layer.open({
                    id:1,
                    type: 1,
                    title:'审核拒绝',
                    skin:'layui-layer-rim',
                    area:['450px', '300px'],
                    content: ' <div class="row" style="width: 420px;  margin-left:7px; margin-top:10px;">'
                        +'<div class="col-sm-12">'
                        +'<div class="input-group">'
                        +'<span class="input-group-addon"> 拒绝理由   :</span>'
                        +'<textarea id="ref-msg" name="文本域名称”value = "${electricityUser.refuseMsg}"></textarea>'
                        +'</div>'
                        +'</div>'
                        +'</div>'
                    ,
                    btn:['保存','取消'],
                    btn1: function (index,layero) {
                        var refuseMsg=layero.find('#ref-msg').val();
                        $.post("${base}/admin/electricityUser/refuse", {"id": data.userId,"refuseMsg":refuseMsg}, function (res) {
                            if (res.success) {
                                layer.msg("审核成功", {time: 1000}, function () {
                                    location.reload();
                                });
                            } else {
                                layer.msg(res.message);
                            }

                        });

                    },
                    btn2:function (index,layero) {
                    }
                });
            }
            if(obj.event === "refusePwd") {
                layer.confirm("是否确定重置密码？", {btn: ['是的,我确定', '我再想想']},
                    function () {
                        $.post("${base}/admin/electricityUser/changePwd", {"id": data.userId}, function (res) {
                            if (res.success) {
                                layer.msg("重置密码成功！", {time: 1000}, function () {
                                    location.reload();
                                });
                            } else {
                                layer.msg(res.message);
                            }

                        });
                    }
                )
            }

        });

        var t = {
            elem: '#test',
            url:'${base}/admin/electricityUser/list',
            method:'post',
            page: { //支持传入 laypage 组件的所有参数（某些参数除外，如：jump/elem） - 详见文档
                layout: ['limit', 'count', 'prev', 'page', 'next', 'skip'], //自定义分页布局
                //,curr: 5 //设定初始在第 5 页
                groups: 2, //只显示 1 个连续页码
                first: "首页", //显示首页
                last: "尾页", //显示尾页
                limits:[3,10, 20, 30]
            },
            cellMinWidth: 80, //全局定义常规单元格的最小宽度，layui 2.2.1 新增
            cols: [[
                // {type:'checkbox',width:'50'},
                {field:'userId', title: '用户id',width:'150'},
                {field:'userName', title: '昵称',width:'150'},
                {field:'phone', title: '手机号',width:'150'},
                {field:'memberType', title: '市场成员类型',width:'130'},
                {field:'companyName', title: '公司名称',width:'150'},
                {field:'isDelete', title: '是否拉黑',width:'150'},
                {field:'isCheck', title: '审核是否通过',width:'150'},
                {field:'isPerfectInfo', title: '是否已完善企业信息',width:'160'},
                {field:'createDate',  title: '注册时间',width:'200',templet:'<div>{{ layui.laytpl.toDateString(d.createDate) }}</div>',unresize: true}, //单元格内容水平居中
                {fixed: 'right', title:'操作',  width: '400', align: 'center',toolbar: '#barDemo'}
            ]],
            done: function (res, curr, count) {
                $("[data-field='isDelete']").children().each(function () {
                    if ($(this).text() == '0') {
                        $(this).text('已拉黑');
                    } else if ($(this).text() == '1') {
                        $(this).text('正常');
                    }else if ($(this).text() == '3') {
                        $(this).text('取消拉黑');
                    }else if ($(this).text() == '2') {
                        $(this).text('已到期');
                    }

                });
                $("[data-field='isPerfectInfo']").children().each(function () {
                    if ($(this).text() == '0') {
                        $(this).text('已完善');
                    } else if ($(this).text() == '1') {
                        $(this).text('未完善');
                    }
                });
                $("[data-field='isCheck']").children().each(function () {
                    var a = $(this).text();
                    if($(this).text() == '0'){
                        $(this).text('审核中');
                    }else if ($(this).text() == '1') {
                        $(this).text('审核通过');
                    } else if ($(this).text() == '2'){
                        $(this).text('审核拒绝');
                    }
                });
                $("[data-field='memberType']").children().each(function () {
                    if ($(this).text() == '0') {
                        $(this).text('发电企业');
                    } else if ($(this).text() == '1') {
                        $(this).text('售电公司');
                    }else if ($(this).text() == '2') {
                        $(this).text('电力用户');
                    }
                });
            }
        };
        table.render(t);

        var active={
            addElectricityUser : function(){
                var addIndex = layer.open({
                    title : "添加用户信息表",
                    type : 2,
                    content : "${base}/admin/electricityUser/add",
                    success : function(layero, addIndex){
                        setTimeout(function(){
                            layer.tips('点击此处返回用户信息表列表', '.layui-layer-setwin .layui-layer-close', {
                                tips: 3
                            });
                        },500);
                    }
                });
                //改变窗口大小时，重置弹窗的高度，防止超出可视区域（如F12调出debug的操作）
                $(window).resize(function(){
                    layer.full(addIndex);
                });
                layer.full(addIndex);
            }
        };

        $('.layui-inline .layui-btn-normal').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

        form.on("submit(searchForm)",function(data){
            t.where = data.field;
            table.reload('test', t);
            return false;
        });

    });
</script>
</body>
</html>
